#include "changenotifydialog.h"
#include "ui_changenotifydialog.h"
#include <Windows.h>

#include <QtGui/QFileDialog>
#include <iostream>


using namespace std;

ChangeNotifyDialog::ChangeNotifyDialog(QWidget *parent) :
    QDialog(parent)//, m_notifyThread(NULL)
{
    setupUi(this);
}

ChangeNotifyDialog::~ChangeNotifyDialog()
{
}


void ChangeNotifyDialog::on_pushButton_clicked()
{
    qDebug("opening file for monitoring");

    QString dirName = QFileDialog::getExistingDirectory(
	    this,
	    tr("Open Directory"),
	    "/",
	    QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);

    this->lineEdit->setText(dirName);

    qDebug(qPrintable(dirName));


    ChangeNotifyThread *notifyThread = new ChangeNotifyThread(this, dirName);
    m_notifyThreads.push_back(notifyThread);
    notifyThread->start();

    qDebug("thread has started");

    connect(notifyThread, SIGNAL(updateDir(QString)), this, SLOT(on_updateDir(QString)));

}

void ChangeNotifyDialog::on_updateDir(QString dir)
{
    cout << "eba from " << dir.toStdString() << endl;
}
